/* pipconnect.c - pipconnect */

#include <xinu.h>
#include <mips.h>

syscall   pipconnect(
		pipid32         pipid,             /* ID of pipe to connect   */
		pid32		end1,
		pid32		end2
        )
{
	intmask mask;                   /* saved interrupt mask         */
	struct pipent *piptr;		/* ptr to pipe's table entry	*/

	mask = disable();		/* saved interrupt mask         */

	if (	isbadpipid(pipid)
		|| (isbadpid(end1)) || (isbadpid(end2)) 
		|| (piptr->pistate != PIPE_USED)) 
	{
                restore(mask);
                return SYSERR;
        }

	piptr = &piptab[pipid];

	piptr->pistate = PIPE_CONNECTED;
	restore(mask);
	return OK;
}
